package com.ruoyi.system.controller;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.constant.RocketMqConstants;
import com.ruoyi.system.config.rocketmq.RocketMQProducer;
import com.ruoyi.system.domain.DjiAirport;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/RocketMQ")
public class RocketMQController {

    private final String topic = "topic1";

    @Resource
    private RocketMQProducer producer;

    @RequestMapping("/sendMessage")
    public String sendMessage(String message) {
        DjiAirport djiAirport = new DjiAirport();
        djiAirport.setSn("1233");
        djiAirport.setAirportName("测试机场");
        djiAirport.setLongitude("30.22222");
        djiAirport.setLatitude("120.032311");

        producer.sendMessage(RocketMqConstants.AIRPORT_INFO, JSONObject.toJSONString(djiAirport));
        return "消息已发送";
    }
}
